/***********************************************************************//**
 *   \file Sample.h		\author belot nicolas (karrakis)           
 *   \brief define Class Sample                                            
 *   an interface for managing samples                                     
 ************************************************************************//*
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
****************************************************************************/

#ifndef SAMPLE_H
#define SAMPLE_H 1

#define MIN_BUFF_SIZE 4096
#include <sys/types.h>
#include <string>
#include "Buffer.h"
using namespace std;
namespace libtrckr {
class Sample {
	/** \class libtrckr::Sample
	\brief An interface for accessing to sample.
	*/
	public:
		//Constructor
		/** Default Construct*/
		Sample();
		/*Sample(string);*/
		/** Copy Constructor */
		Sample(Sample&);
		/** Desctructor */
		virtual ~Sample();
		//Reader
		/** Read data and return it in \c double format */		
		virtual loff_t read(double*, int )=0;//read int double
		/** Read data and return it in \c float format */
		virtual loff_t read(float*, int )=0;
		/** Read data and return it in \c int format */
		virtual loff_t read(int *, int )=0;
		/** Read data and return it in \c short format */
		virtual loff_t read(short*, int )=0;
		//Special reader
		/** Read date in double format and return a Buffer*/
		virtual Buffer read(int)=0;
		/** Read data and load the buffer with*/
		virtual void read(Buffer&)=0;
		//Accessor
		/** return the bitrate */
		int getBitrate() const;
		/** set the bitrate */
		void setBitrate(int);
		/**return the number of Channels*/
		virtual int channels() const=0;
		/** get The format of the Sample */
		virtual string getFormat() = 0; //A string Format  dataType XI PCM 16 bit
		/** Specify the Format of the Sample */
		virtual void setFormat(int,int,int)=0;
		/** Position the handler in the Sample */
		virtual bool seek(long)=0; //seek in TIME get a µsecond parameter 
		/** the length of the sample */
		virtual loff_t getLength( ) const=0;//return the length of the sample
		/** Did we reach the end of the file */
		virtual bool   isEOF() const =0;

		virtual bool isValid() const = 0;	
	private:
		int _bitrate;
//static part
/*	public :
		static bool BufferAllocate(int);
		static void BufferDesallocate( );
		static void* _buffer;*/
};
	/** loads Buffer with Sample
	\param b the Buffer
	\param s the Sample
	\return the Buffer
	*/
	Buffer& operator<<(Buffer&,Sample&);
	Buffer& operator>>(Buffer&,Sample&);
}
#endif

